<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class UserVisit extends Model
{
    use HasFactory;
    use PimpableTrait;
    use SoftDeletes;

    /**
     * 默认排序
     */
    protected $defaultSortCriteria = ['id,desc'];

    /**
     * 可排序字段
     */
    public $sortable = [
        'created_at',
        'id',
        'user_id',
        'stay_time',
        'province',
    ];

    /**
     * 可搜索字段
     */
    public $searchable = [
        'user_id',
        'url',
        'ip',
        'stay_time',
        'province',
        'content',
    ];
    /**
     * 用户访问表可批量复制字段
     */
    protected $fillable = [
        'user_id',
        'url',
        'stay_time',
        'ip',
        'channel_type',
        'province',
        'content',
    ];
    /**
     * 访问的用户
     */
    public function userVisit(){
        return $this->hasMany(User::class,'user_id','id');
    }
}
